﻿@using RGA.Models
@model RGA.Models.CreateUserViewModel

@{
    ViewBag.Title = "Edytuj użytkowników";
    //Layout = "_Layout";
    //var model = new CreateUserViewModel();
}

<h2>Edytuj użytkowników</h2>

<table border="1">
    <thead>
        <tr>
            <td>Id</td>
            <td>Nazwa</td>
            <td>E-mail</td>
            <td>Numer telefonu</td>
            <td>Rola</td>
            <td> </td>
            <td> </td>
        </tr>
    </thead>
    <tbody>
        @foreach (User item in Model.users)
        {
            <tr>
                <td>
                    @Html.Encode(item.Id)
                </td>

                <td>
                    @Html.Encode(item.UserName)
                </td>

                <td>
                    @Html.Encode(item.Email)
                </td>

                <td>
                    @Html.Encode(item.PhoneNumber)
                </td>

                <td>
                    @Html.Encode(item.Role.Name)
                </td>
                <td>
                    @Html.ActionLink("Edytuj", "Edit", new {item.Id})
                </td>
                <td>
                    @Html.ActionLink("Usuń", "Delete", new {item.Id})
                </td>
            </tr>
        }
    </tbody>
</table>

<br/>

<h2>Dodaj użytkownika</h2>


@using (Html.BeginForm("Register", "ManageUsers", FormMethod.Post, new {@class = "form-horizontal", role = "form"}))
{
    @Html.AntiForgeryToken()
    <h4>Utwórz nowe konto.</h4>
    <hr />
    @Html.ValidationSummary("", new {@class = "text-danger"})
    <div class="form-group">
        @Html.LabelFor(m => m.Username, new {@class = "col-md-2 control-label"})
        <div class="col-md-10">
            @Html.TextBoxFor(m => m.Username, new {@class = "form-control"})
        </div>
    </div>
    <div class="form-group">
        @Html.LabelFor(m => m.Email, new {@class = "col-md-2 control-label"})
        <div class="col-md-10">
            @Html.TextBoxFor(m => m.Email, new {@class = "form-control"})
        </div>
    </div>

    <div class="form-group">
        @Html.LabelFor(m => m.Phone, new {@class = "col-md-2 control-label"})
        <div class="col-md-10">
            @Html.TextBoxFor(m => m.Phone, new {@class = "form-control"})
        </div>
    </div>

    <div class="form-group">
        @Html.LabelFor(m => m.Role, new {@class = "col-md-2 control-label"})
        <div class="col-md-10">
            @Html.ListBoxFor(m => m.Role,
                new SelectList(new List<SelectListItem> {new SelectListItem {Value = "Kierowca", Text = "Kierowca", Selected = true}, new SelectListItem {Value = "Pracownik", Text = "Pracownik"}, new SelectListItem {Value = "Admin", Text = "Admin"}}, "Value", "Text"),
                new {@class = "form-control"})
        </div>
    </div>

    <div class="form-group">
        @Html.LabelFor(m => m.Password, new {@class = "col-md-2 control-label"})
        <div class="col-md-10">
            @Html.PasswordFor(m => m.Password, new {@class = "form-control"})
        </div>
    </div>
    <div class="form-group">
        @Html.LabelFor(m => m.ConfirmPassword, new {@class = "col-md-2 control-label"})
        <div class="col-md-10">
            @Html.PasswordFor(m => m.ConfirmPassword, new {@class = "form-control"})
        </div>
    </div>
    <div class="form-group">
        <div class="col-md-offset-2 col-md-10">
            <input type="submit" class="btn btn-default" value="Register" />
        </div>
    </div>
}

@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
}